@echo off
setlocal enabledelayedexpansion
:: Check for Administrator privileges
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo Please run this script as Administrator.
    exit /b
)

:: 1. Enable Remote Desktop
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
echo Remote Desktop has been enabled.

:: 2. Configure local security policy
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Lsa" /v LimitBlankPasswordUse /t REG_DWORD /d 0 /f
echo Local accounts with blank passwords are now allowed for remote logins.

:: 3. Set power plan to High Performance
powercfg /setactive e9a42b02-d5df-448d-aa00-03f14749eb61
echo Power plan set to High Performance.

:: 4. Disable lock screen and sleep mode
reg add "HKCU\Control Panel\Desktop" /v ScreenSaveActive /t REG_DWORD /d 0 /f
powercfg /change standby-timeout-ac 0
powercfg /change standby-timeout-dc 0
powercfg /change monitor-timeout-ac 0
powercfg /change monitor-timeout-dc 0
echo Lock screen and sleep mode have been disabled.

:: 5. Disable firewall
netsh advfirewall set allprofiles state off
echo Firewall has been disabled.

:: 6. Set time zone to China Standard Time (UTC+8)
tzutil /s "China Standard Time"
echo Time zone set to China Standard Time.
:: set ntp server 172.16.100.6
sc config w32time start= auto && net start w32time
w32tm /config /manualpeerlist:"172.16.100.6" /syncfromflags:manual /update
w32tm /resync /force
echo NTP server set to 172.16.100.6

:: 7. Disable Windows Update service
sc stop wuauserv
sc config wuauserv start= disabled
echo Windows Update service has been disabled.

:: 8. Disable Windows Search service
sc stop WSearch
sc config WSearch start= disabled
echo Windows Search service has been disabled.

:: 9. Disable Superfetch
sc stop sysmain
sc config sysmain start= disabled
echo Superfetch service has been disabled.

:: 10. Disable System Restore
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" /v "DisableSR" /t REG_DWORD /d 1 /f
echo System Restore has been disabled.

:: 11. Disable IPv6
echo Available Network Interfaces:
for /f "tokens=2 delims==" %%A in ('wmic nic where "NetConnectionID IS NOT NULL" get NetConnectionID /value ^| findstr "="') do (
    set INTERFACE_NAME=%%A
    echo !INTERFACE_NAME!
)
set /p INTERFACE_NAME="Enter the network interface name: "
powershell -Command "Disable-NetAdapterBinding -Name '!INTERFACE_NAME!' -ComponentID ms_tcpip6"

:: 12. Set IPv4 address, subnet mask, and gateway
set /p IP_ADDR="Enter IPv4 Address: "
set /p GATEWAY="Enter Gateway: "
set SUBNET_MASK=255.255.255.0

echo Configuring IPv4...
netsh interface ip set address name="!INTERFACE_NAME!" static %IP_ADDR% %SUBNET_MASK% %GATEWAY%

:: 12. Optimize memory paging file (fixed size: 4096MB)
wmic pagefileset where name="C:\\pagefile.sys" set InitialSize=4096, MaximumSize=4096
echo Memory paging file optimized to fixed size 4096MB.

:: 13. Set user interface language to English (United States)
powershell Set-WinUILanguageOverride -Language "zh-CN"
powershell Set-WinUserLanguageList -LanguageList "en-US" -Force
echo User interface language set to English (United States).

echo All operations completed. Please restart your computer to apply the changes.
